Skip to content

nxboot: enhance the access to flash device #3136

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 28, 2025

Conversation

michallenc
Copy link
Contributor

Summary

619ea01 boot/nxboot/loader/flash.c: open partition with O_DIRECT flag

There is no need to use buffers in a bootloader. We expect a sequential
access, therefore we just need to erase the erase page before writing
to it for the first time, which is something FTL layer already takes
care of.

95e4b0c boot/nxboot/loader/boot.c: copy partition with blocksize large writes

The previous logic MAX(info_from.blocksize, info_where.blocksize) was
incorrect. The most effective access with by writing the entire
size of the block, therefore just decide the size based on the
target page size.

Impact

Nxboot now utilizes changes presented in apache/nuttx#16642. Should not have impact on current implementation as the additional flags are ignored if changes in apache/nuttx#16642 are not applied.

Testing

Tested with apache/nuttx#16642 patch applied. Nxboot successfully updates and reverts new image. All works as before, but additional buffering is skipped.

There is no need to use buffers in a bootloader. We expect a sequential
access, therefore we just need to erase the erase page before writing
to it for the first time, which is something FTL layer already takes
care of.

Signed-off-by: Michal Lenc <[email protected]>
The previous logic MAX(info_from.blocksize, info_where.blocksize) was
incorrect. The most effective access with by writing the entire
size of the block, therefore just decide the size based on the
target page size.

Signed-off-by: Michal Lenc <[email protected]>
@michallenc
Copy link
Contributor Author

@TimJTi adding this as a draft now, could you test it with your environment when you have time? Thanks!

@michallenc michallenc changed the title Nxboot direct access nxboot: enhance the access to flash device Jul 17, 2025
@TimJTi
Copy link
Contributor

TimJTi commented Jul 17, 2025

@TimJTi adding this as a draft now, could you test it with your environment when you have time? Thanks!

@michallenc Of course - probably not until next week though: hope that's OK.

@michallenc
Copy link
Contributor Author

michallenc commented Jul 17, 2025

@TimJTi adding this as a draft now, could you test it with your environment when you have time? Thanks!

@michallenc Of course - probably not until next week though: hope that's OK.

Absolutely, this is just a quiality of life change, no need for a quick merge.

@michallenc
Copy link
Contributor Author

@TimJTi Hi, did you find time to test the patch? Thanks.

@TimJTi
Copy link
Contributor

TimJTi commented Jul 28, 2025

Today's task (one of). Sorry for the delay !

@TimJTi
Copy link
Contributor

TimJTi commented Jul 28, 2025

@michallenc @xiaoxiang781216
I can confirm this work nicely on my board. I rebuilt my bootloader with this patch, uploaded a new secondary image and it correctly copied primary to backup and secondary to primary. I did not validate the new image, and it correctly reverted primary to the backup image.

And it seems very much faster too, unless it's my imagination!?

PS: I found an error in my recently added progress percentage display for NXBoot, and will shortly submit a small PR for that.

@michallenc michallenc marked this pull request as ready for review July 28, 2025 14:24
@michallenc
Copy link
Contributor Author

@michallenc @xiaoxiang781216 I can confirm this work nicely on my board. I rebuilt my bootloader with this patch, uploaded a new secondary image and it correctly copied primary to backup and secondary to primary. I did not validate the new image, and it correctly reverted primary to the backup image.

And it seems very much faster too, unless it's my imagination!?

PS: I found an error in my recently added progress percentage display for NXBoot, and will shortly submit a small PR for that.

Thanks! Yes, it should in theory be faster with the direct access, we avoid some unnecessary buffering and erases.

@TimJTi
Copy link
Contributor

TimJTi commented Jul 28, 2025

Thanks! Yes, it should in theory be faster with the direct access, we avoid some unnecessary buffering and erases.

Excellent 👍

Copy link
Contributor

@cederom cederom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @michallenc great work! Also thank you @TimJTi for verification! :-)

@cederom cederom merged commit 8fbba09 into apache:master Jul 28, 2025
67 of 75 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants